package com.zhangxun.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhangxun.doc.ProdEs;
import com.zhangxun.service.EsSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "es搜索服务接口管理")
public class SearchController {

    @Autowired
    private EsSearchService esSearchService;

    @GetMapping("/prod/prodListByTagId")
    @ApiOperation("通过标签查询商品接口")
    public Page<ProdEs> prodListByTagId(Page<ProdEs> page,Long tagId){

        page = esSearchService.prodListByTagId(page,tagId);

        return page;

    }


    @GetMapping("/search/searchProdPage")
    @ApiOperation("分页查询搜索关键字接口")
    public Page<ProdEs> searchProdPage(Page<ProdEs> page, String prodName, Integer sort){
        page = esSearchService.selectPage(page,prodName,sort);
        return page;

    }

    @GetMapping("/prod/pageProd")
    @ApiOperation("根据分类id查询商品")
    public Page<ProdEs> searchByCategoryId(Long cateGoryId){

     Page<ProdEs> page = esSearchService.searchByCategoryId(cateGoryId);

       return page;
    }
}
